using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Backend.JYD.Model.Task;

namespace Backend.JYD.EFDAL.Mapping
{
    public class TaskStepModelMap : EntityTypeConfiguration<TaskStepModel>
    {
        public TaskStepModelMap()
        {
            // Primary Key
            this.HasKey(t => t.TaskStepId);

            // Properties
            this.Property(t => t.StepName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.LastStepIds)
                .HasMaxLength(50);

            this.Property(t => t.NextStepIds)
                .HasMaxLength(50);

            this.Property(t => t.RoleIds)
                .HasMaxLength(50);

            this.Property(t => t.EmpIds)
                .HasMaxLength(50);
            this.Property(t => t.StepCode)
                .HasMaxLength(50);
            this.Property(t => t.AuthIds)
                .HasMaxLength(200);
            
            // Table & Column Mappings
            this.ToTable("TaskStepModel");
            this.Property(t => t.TaskStepId).HasColumnName("TaskStepId");
            this.Property(t => t.StepId).HasColumnName("StepId");
            this.Property(t => t.StepName).HasColumnName("StepName");
            this.Property(t => t.TaskModeId).HasColumnName("TaskModeId");
            this.Property(t => t.StepCode).HasColumnName("StepCode");
            this.Property(t => t.LastStepIds).HasColumnName("LastStepIds");
            this.Property(t => t.NextStepIds).HasColumnName("NextStepIds");
            this.Property(t => t.AllowLoop).HasColumnName("AllowLoop");
            this.Property(t => t.AllowStop).HasColumnName("AllowStop");
            this.Property(t => t.UseRole).HasColumnName("UseRole");
            this.Property(t => t.RoleIds).HasColumnName("RoleIds");
            this.Property(t => t.EmpIds).HasColumnName("EmpIds");
            this.Property(t => t.AuthIds).HasColumnName("AuthIds");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.CreateTime).HasColumnName("CreateTime");
            this.Property(t => t.UpdateTime).HasColumnName("UpdateTime");
            this.Property(t => t.OpId).HasColumnName("OpId");

            // Relationships
            this.HasRequired(t => t.TaskModel)
                .WithMany(t => t.TaskStepModels)
                .HasForeignKey(d => d.TaskModeId);

        }
    }
}
